/** 
 *  @file
 *  @brief   槽（C）形1（CHAN1）梁截面属性使用解析公式计算类
 *  @author  xiaochangjiang
 *  @date    2024.04.03
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "Chan1SectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"
#include "ChanSectionFormulaCalculator.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::ChanSectionFormulaCalculator;
using SG::FEMSolver::Element::Chan1SectionFormulaCalculator;

void Chan1SectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    /* NASTRAN 的 CHAN1 形梁截面转换成 CHAN 形梁截面
     * 
     * chan.dim1 = chan1.dim1 + chan1.dim2
     * chan.dim2 = chan1.dim4
     * chan.dim3 = chan1.dim2
     * chan.dim4 = (chan1.dim4 - chan1.dim3) / 2
     * 详细请参考 NASTRAN 手册
     */
    Real dim2{section.m_dimension[3]};
    Real dim3{section.m_dimension[1]};
    Real dim1{dim3 + section.m_dimension[0]};
    Real dim4{0.5 * (dim2 - section.m_dimension[2])};
    PBARLData chanSection{section};
    chanSection.m_dimension = {dim1, dim2, dim3, dim4};

    ChanSectionFormulaCalculator chanCalculator;
    chanCalculator.Compute (chanSection, _OUT property, _OUT centroid);
}